package com.atguigu.springcloud.service;

import com.atguigu.springcloud.entities.Employee;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * Created by luojie on 2018/9/20.
 */
@Component
public class EmployeeClientServiceFallbackFactory implements FallbackFactory<EmployeeClientService> {
    @Override
    public EmployeeClientService create(Throwable throwable) {
        return new EmployeeClientService() {
            @Override
            public Employee findById(@PathVariable("id") String id) {
                Employee employee = new Employee();
                employee.setId(id);
                employee.setName("没有对应的信息");
                return employee;
            }

            @Override
            public Employee save(Employee employee) {
                return employee;
            }
        };
    }
}
